// ActionScript file
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
/**
 * 读取用户上传的图片
 */
private function getMyPhotoRPCResult(event:ResultEvent):void{
	//trace(event.result);
	var tmp:Array = new Array();
	for each (var s:XML in event.result.info)
	{
		//trace(s.name);
		//tmp.push({name: s.name, urlx: s.urlx});
		MyUploadPhotos.addItem({name: s.name, urlx: s.urlx,width:s.width, height:s.height});
	}
	
	//trace('上传图片加载完毕');
	myphoto = MyUploadPhotos;
	//trace();
}

/**
 * 发送HTTPService 
 * @param String url
 * @param Object param
 * @param Function Callback
 * 
 */
private function SendHttpService( url:String, param:Object = null, Callback:Function = null, name:String='' ):void
{
	var httpServiceObj:HTTPService = new HTTPService();
	httpServiceObj.resultFormat = "e4x";
	httpServiceObj.method = "POST";
	httpServiceObj.url = url;
	httpServiceObj.addEventListener(FaultEvent.FAULT, function(event:FaultEvent):void{doFault(event,name)} );
	httpServiceObj.addEventListener(ResultEvent.RESULT, Callback );
	httpServiceObj.send(param);
}
// do fault for HTTPService
private function doFault(event:FaultEvent, name:String):void{
	trace(name+' is Fault.');
	//event.target.sent();
	this.process1.label = name+'加载失败。 '+this.countForLoad;
} 


// for Stages HTTPService
private function StagesRPCResult(event:ResultEvent):void
{
	
	for each (var s:XML in event.result.second)
	{
		//var se:Array = new Array({s:@name});
		//trace(s.@name);
		StageMenu.push({name: s.@name.toString()});
		var tmp:Array=new Array();
		for each (var se:XML in s.info)
		{
			//trace(se.name);
			tmp.push({name: se.name, urlx: se.urlx});
		}
		Stages.addItem(tmp);
	}
	process1.label = '加载场景完成 '+this.countForLoad;
	this.countForLoad--;
	trace('stage @ '+this.countForLoad.toString());
	//removeProcess1();
}

// for jewelry HTTPService
private function JewelryRPCResult(event:ResultEvent):void
{
	
	for each (var s:XML in event.result.second)
	{
		//var se:Array = new Array({s:@name});
		//trace(s.@name);
		JewelryMenu.push({name: s.@name.toString()});
		var tmp:Array=new Array();
		for each (var se:XML in s.info)
		{
			//trace(se.name);
			tmp.push({name: se.name, urlx: se.urlx});
		}
		Jewelrys.addItem(tmp);
	}
	process1.label = '加载饰品完成 '+this.countForLoad;
	this.countForLoad--;
	trace('jewelry @ '+this.countForLoad.toString());
	//removeProcess1();
}

// for boder HTTPService
private function BorderRPCResult(event:ResultEvent):void
{
	
	//trace(event.result);
	//Borders = event.result.root.second;
	
	for each (var s:XML in event.result.second)
	{
		//var se:Array = new Array({s:@name});
		//trace(s.@name);
		BorderMenu.push({name: s.@name.toString()});
		var tmp:Array=new Array();
		for each (var se:XML in s.info)
		{
			//trace(se.name);
			tmp.push({name: se.name, urlx: se.urlx});
		}
		Borders.addItem(tmp);
	}
	process1.label = '加载边框完成 '+this.countForLoad;
	this.countForLoad--;
	trace('border @ '+this.countForLoad.toString());
	//removeProcess1();
}


// for text HTTPService
private function TextRPCResult(event:ResultEvent):void
{
	
	for each (var s:XML in event.result.second)
	{
		//var se:Array = new Array({s:@name});
		//trace(s.@name);
		TextMenu.push({name: s.@name.toString()});
		var tmp:Array=new Array();
		for each (var se:XML in s.info)
		{
			//trace(se.name);
			tmp.push({name: se.name, urlx: se.urlx});
		}
		Texts.addItem(tmp);
	}
	process1.label = '加载文字完成 '+this.countForLoad;
	this.countForLoad--;
	trace('text @ '+this.countForLoad.toString());
	//removeProcess1();
}


// for calendar HTTPService
// 取消
private function CalendarRPCResult(event:ResultEvent):void
{
	
	for each (var s:XML in event.result.info)
	{
		//var se:Array = new Array({s:@name});
		//trace(s.@name);
		
		Calendars.addItem({name: s.name, urlx: s.urlx});
	}
	process1.label = '加载日历完成 '+this.countForLoad;
	this.countForLoad--;
	trace('calendar @ '+this.countForLoad.toString());
	//removeProcess1();
}


/**
 * Maked HTTPService成功
 * 
 */
private function MakedRPCResult(event:ResultEvent):void
{
	
	for each (var s:XML in event.result.info)
	{
		mymaked.addItem({name: s.name, urlx: s.urlx,urls: s.urls, width:s.width, height:s.height});
		trace(s);
	}
	
	
	trace('Load Maked @ Done');
	
}



